app.controller('shopDeliveryCtrl', ['$scope', '$state', '$cookies', '$modal', 'shopDeliveryService', 'utilService', 'toaster', function ($scope, $state, $cookies, $modal, shopDeliveryService, utilService, toaster) {

    $scope.sessionId = $cookies.sessionId;
    $scope.shopDeliveryList = [];

    $scope.inint = function () {
        $scope.queryAll();
    }

    $scope.queryAll = function () {
        shopDeliveryService.queryAll($scope).then(function (result) {
            switch (result.status) {
                case 200:
                    $scope.shopDeliveryList = result.data;
                    break;
                default:
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break;
            }
        });
    }

    $scope.delete = function (id) {
        if (id == null || id == '') {
            toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
            return;
        }
        $scope.shopDeliveryId = id;
        shopDeliveryService.delete($scope).then(function (result) {
            switch (result.status) {
                case 200:
                    toaster.pop('success', "提示", "操作成功");
                    $scope.queryAll();
                    break;
                default:
                    if (result.message != null) {
                        toaster.pop('error', "操作失败", result.message);
                    } else {
                        toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    }
                    break;
            }
        });
    }

    //模态提示框
    // $scope.openAdd = function (size) {
    //     var modalInstance = $modal.open({
    //         templateUrl: '',
    //         controller: 'shopDeliveryDeleteCtrl',
    //         size: "sm",
    //         resolve: {
    //             unreadResult: function () {
    //                 return $scope.unreadResult;
    //             },
    //             domain: function () {
    //                 return src;
    //             }
    //         }
    //     });
    //     modalInstance.result.then(function (selectedItem) {
    //         $scope.queryAll();
    //     }, function () {

    //     });
    // };

}]);

app.controller('shopDeliveryDeleteCtrl', ['$scope', '$modalInstance', '$cookies', 'shopDeliveryService', 'toaster', function ($scope, $modalInstance, $cookies, shopDeliveryService, toaster) {
   
    $scope.ok = function () {
        
    };

    $scope.cancel = function () {
        console.log('456');
        $modalInstance.dismiss('cancel');
    };

}]);
